/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package Bankmanagement;

/**
 *
 * @author ashongtical
 */
public class BankAccount {
        private String accountNumber;
        private double balance;
        private int depositsCount;
        private int withdrawalsCount;
        private double annualInterestRate;
        private double monthlyServiceCharges;

        public BankAccount(String accountNumber, double balance, double annualInterestRate) {
            this.accountNumber = accountNumber;
            this.balance = balance;
            this.annualInterestRate = annualInterestRate;
            this.depositsCount = 0;
            this.withdrawalsCount = 0;
            this.monthlyServiceCharges = 0;
        }

        public String getAccountNumber() {
            return accountNumber;
        }

        public void deposit(double amount) {
            if (amount <= 0) {
                throw new IllegalArgumentException("Deposit amount must be positive.");
            }
            balance += amount;
            depositsCount++;
        }

        public void withdraw(double amount) {
            if (amount <= 0) {
                throw new IllegalArgumentException("Withdrawal amount must be positive.");
            }
            if (balance - amount < 25) {
                throw new IllegalStateException("Withdrawal denied. Balance would drop below RMB 25.00.");
            }
            balance -= amount;
            withdrawalsCount++;
        }

        public void calcInterest() {
            double monthlyInterest = (balance * annualInterestRate) / 12;
            balance += monthlyInterest;
        }

        public void monthlyProcess() {
            balance -= monthlyServiceCharges;
            calcInterest();
            depositsCount = 0;
            withdrawalsCount = 0;
            monthlyServiceCharges = 0;
            System.out.println("Monthly processing completed.");
        }

        public void displayAccountDetails() {
            System.out.println("Account Number: " + accountNumber);
            System.out.println("Balance: RMB " + balance);
            System.out.println("Deposits this month: " + depositsCount);
            System.out.println("Withdrawals this month: " + withdrawalsCount);
        }

        public double getBalance() {
            return balance;
        }

        public int getDepositsCount() {
            return depositsCount;
        }

        public int getWithdrawalsCount() {
            return withdrawalsCount;
        }

        public double getAnnualInterestRate() {
            return annualInterestRate;
        }

        public void setAnnualInterestRate(double annualInterestRate) {
            this.annualInterestRate = annualInterestRate;
        }

        public double getMonthlyServiceCharges() {
            return monthlyServiceCharges;
        }

        public void setMonthlyServiceCharges(double monthlyServiceCharges) {
            this.monthlyServiceCharges = monthlyServiceCharges;
        }
    }